//
//  WXPLoanAgreementVC.m
//  MexicoLoan
//
//  Created by wxp on 2025/2/26.
//

#import "WXPLoanAgreementVC.h"

@interface WXPLoanAgreementVC ()<WKUIDelegate, WKNavigationDelegate>

@end

@implementation WXPLoanAgreementVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navView resetViewWithTitle:@"Acuerdo de Prestamo"];
    self.navView.btnService.hidden = false;
}

- (void)loadWebView{
    // 打点
    [GlobalMethod hitPointWithPageName:KEY_Agreement action:KEY_Enter extInfo:@{@"type": @"Loan"}];
    NSString * html = [NSString stringWithFormat:@"%@%@",DOMAIN_NAME, self.htmlStr];
    html = [html stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    
    NSLog(@" ------ %@", html);
    
    [self.webView loadRequest:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:html]]];
    self.webView.UIDelegate = self;
    self.webView.navigationDelegate = self;
}

#pragma mark - WKNavigationDelegate
// 页面开始加载时调用
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {
    // 显示加载指示器
    [self showLoadingView];
}

// 页面加载完成时调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
    // 隐藏加载指示器
    [self.loadingView hideLoading];
}

// 页面加载失败时调用
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
    NSLog(@"WebView load error: %@", error.localizedDescription);
    // 隐藏加载指示器
    [self.loadingView hideLoading];
}

@end
